var $form;
$(function(){
    $form = $("#dataForm").validate();
})

function doSubmit(){

    var valid = $("#dataForm").valid();
    if(!valid){
        return false;
    }

    console.log($('#dataForm').serialize());

    var url = ctx+'/admin/user/doSave';
    if($('#dataForm input[name=id]').val()){
        url = ctx+'/admin/user/doUpdate';
    }
    if(valid){
        $.ajax({
            type:'post',
            url:url,
            data:$('#dataForm').serialize(),
            dataType:'json',
            success:function(resp){
                if('OK'==resp.code){
                    location.href = ctx+'/admin/user/list';
                }else if("NO" == resp.code){
                    layer.msg('提交失败');
                }else if("-91" == resp.code){
                    layer.msg('用户名已存在');
                }else if("-92" == resp.code){
                    layer.msg('手机已存在');
                }else if("-93" == resp.code){
                    layer.msg('邮箱已存在');
                }
            }
        })
    }

}